{extend name="common/public" /}
{block name="content"}

<div class="widget-body am-fr">
    <div class="am-form-group">
        <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <button type="button" onclick="openUrl('{:url('add_ad',['type_id'=>$Request.param.type_id])}')" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</button>
                </div>
        </div>
    </div>
</div>

<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
    <div class="widget am-cf">
        <div class="widget-head am-cf">
            <div class="widget-title am-fl">广告管理</div>
            <div class="widget-function am-fr">
                <a href="javascript:;" class="am-icon-cog"></a>
            </div>
        </div>
        <div class="widget-body  widget-body-lg am-fr">
            <form action="{:url()}">
                <select name="type_id">
                    {foreach $type_list as $v}
                        <option value="{$v.id}" {if $v.id == $Request.param.type_id}selected{/if}>{$v.type_name}</option>
                    {/foreach}
                </select>
                <button type="submit" class="am-btn am-btn-xs am-btn-default am-btn-success"><span class="am-icon-search"></span> 确定</button>
            </form>
            <table width="100%" id="viewer" class="am-table am-table-compact am-table-bordered tpl-table-black ">
                <thead>

                <tr>
                    <th class="am-lg-text-center">
                        图片
                    </th>
                    <th class="am-lg-text-center">
                        标题
                    </th>
                    <th class="am-lg-text-center">
                        跳转链接
                    </th>
                    <th class="am-lg-text-center">
                        是否显示
                    </th>
                    <th class="am-lg-text-center">
                        创建时间
                    </th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>

                {foreach $list as $v}

                <tr class="gradeX">
                    <td class='am-lg-text-center'>
                        <img src="{$v.url}"  data-original="{$v.url}" class="tpl-table-line-img" style="max-width:300px;">
                    </td>
                    <td class='am-lg-text-center'> {$v.title}</td>
                    <td class='am-lg-text-center'> {$v.link}</td>

                    <td class='am-lg-text-center'>
                        <div class="tpl-switch">
                            <input type="checkbox" onchange="setShow(this,'{$v.id}')" name="is_salesman"  class="ios-switch bigswitch tpl-switch-btn am-margin-top-xs" {eq name='$v.is_show' value="1"}checked{/eq}>
                            <div class="tpl-switch-btn-view">
                                <div></div>
                            </div>
                        </div>
                    </td>

                    <td class='am-lg-text-center'> {$v.create_time}</td>

                    <td>

                        <div class="tpl-table-black-operation">
                            <a onclick="openUrl('{:url('editAd',['id'=>$v['id']])}')">
                                <i class="am-icon-pencil"></i> 编辑
                            </a>
                            <a onclick="rms(this,'{:url('rm_ad')}',{$v.id})" class="tpl-table-black-operation-del">
                                <i class="am-icon-trash"></i> 删除
                            </a>
                        </div>

                    </td>

                </tr>

                {/foreach}


                </tbody>
            </table>

            {$list|raw}

        </div>
    </div>
</div>

{/block}
{block name='script'}
<link href="https://cdn.bootcss.com/viewerjs/1.5.0/viewer.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/viewerjs/1.5.0/viewer.js"></script>
<script type="text/javascript">

    var viewer = new Viewer(document.getElementById('viewer'), {
        url: 'data-original'
    });

    function setShow(dom,id) {

        $.get("{:url('setShow')}",{'id':id,'is_show':dom.checked?1:0})
    }
</script>
{/block}
{/extend}
